package com.hao.tool.common.component;

import org.slf4j.Logger;

import java.lang.reflect.Field;

/**
 * description
 *
 * @author RuiHaoZ on CMHK.jx
 * @date 2020-07-10 13:28
 */
public class AppStartTips {

    public static void startTip(Logger log, String applicationName) {
        log.info("\n....................项目启动结果......................\n" +
                "                       _oo0oo_                      \n" +
                "                      o8888888o                     \n" +
                "                      88\" . \"88                     \n" +
                "                      (| -_- |)                     \n" +
                "                      0\\  =  /0                     \n" +
                "                   ___/‘---’\\___                   \n" +
                "                  .' \\|       |/ '.                 \n" +
                "                 / \\\\|||  :  |||// \\                \n" +
                "                / _||||| -卍-|||||_ \\               \n" +
                "               |   | \\\\\\  -  /// |   |              \n" +
                "               | \\_|  ''\\---/''  |_/ |              \n" +
                "               \\  .-\\__  '-'  ___/-. /              \n" +
                "             ___'. .'  /--.--\\  '. .'___            \n" +
                "         .\"\" ‘<  ‘.___\\_<|>_/___.’>’ \"\".          \n" +
                "       | | :  ‘- \\‘.;‘\\ _ /’;.’/ - ’ : | |        \n" +
                "         \\  \\ ‘_.   \\_ __\\ /__ _/   .-’ /  /        \n" +
                "    =====‘-.____‘.___ \\_____/___.-’___.-’=====     \n" +
                "                       ‘=---=’                      \n" +
                "                                                    \n" +
                "................................................... \n" +
                ">>>>>>>>>>>>>>> 项目 " + applicationName + " 启动成功 <<<<<<<<<<<<<");
    }

    public static void startTip(Logger logger, Object object, Class clz) {
        Field[] fields = clz.getDeclaredFields();// 根据Class对象获得属性 私有的也可以获得
        StringBuilder builder = new StringBuilder("");
        for (Field f : fields) {
            try {
                f.setAccessible(true); // 设置些属性是可以访问的
                Object val = f.get(object); // 得到此属性的值
                builder.append("\n");
                builder.append("*** " + String.format("%-18s", f.getName()) + " : " + val);
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
        logger.info(builder.toString());
    }

    public static void out(String name, String value) {
        System.out.println("*** " + ( String.format("%-8s", name)) + " : " + value);

    }
}
